<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../../../assets/docs.css" rel="stylesheet" type="text/css" media="screen" />
<title>MooTools 1.3 Documentation - Request/Request.Periodical</title>
</head>

<body>
  <div class="doc">
    <div class="methods">
      <h4 class="menu-item"><a href="#Request">Request</a></h4>
      <div class="menu-item"><a href="#Request:startTimer">startTimer</a></div>
      <div class="menu-item"><a href="#Request:stopTimer">stopTimer</a></div>
    </div>
    <div class="l-border r-border span-15 content">
      <h1 id="Request"><a href="#Request">Class: Request Periodical</a></h1>
      <p class="description"><em>Request.Periodical.js</em> extends <a href="../../../docs/core/Request/Request.html">Request</a>, <a href="../../../docs/core/Request/Request.HTML">Request.HTML</a>, and <a href="../../../docs/core/Request/Request.JSON.html">Request.JSON</a> to add methods that periodically request the same
        URL but increase the interval if no data is returned from the server. This helps reducing load on a server and prevents pointless requests.
        If any valid response data is returned it resets the interval and executes more requests again.</p>
      <h3>Extends</h3>
      <ul>
        <li> <a href="../../../docs/core/Request/Request.html">Request</a>, <a href="../../../docs/core/Request/Request.HTML">Request.HTML</a>, and <a href="../../../docs/core/Request/Request.JSON.html">Request.JSON</a> </li>
      </ul>
      <h3>Syntax</h3>
      <pre class="javascript"><span class="kw2">var</span> myRequest = <span class="kw2">new</span> Request<span class="br0">(</span>options<span class="br0">)</span>;
myRequest.<span class="me1">startTimer</span><span class="br0">(</span>data<span class="br0">)</span>;
</pre>
      <h3>Options</h3>
      <ul>
        <li>all the options in the original Request.* class, plus:</li>
        <li>initialDelay - (<em>number</em>; defaults to 5000) The initial delay to wait for the request after a call to the start method</li>
        <li>delay - (<em>number</em>; defaults to 5000) The delay between requests and the number of ms to add if no valid data has been returned</li>
        <li>limit - (<em>number</em>; defaults to 60000) The maximum time the interval uses to request the server</li>
      </ul>
      <h3>Example</h3>
      <pre class="javascript"><span class="kw2">new</span> Request<span class="br0">(</span><span class="br0">{</span>
    method: <span class="st0">'post'</span>,
    url: <span class="st0">'foo.php'</span>,
    initialDelay: <span class="nu0">1000</span>,
    delay: <span class="nu0">5000</span>,
    limit: <span class="nu0">15000</span>

<span class="br0">}</span><span class="br0">)</span>.<span class="me1">startTimer</span><span class="br0">(</span><span class="br0">{</span>
    myData: <span class="st0">'value'</span>
<span class="br0">}</span><span class="br0">)</span>;
<span class="co1">// Requests foo.php via post and the provided data initially a second after</span>
<span class="co1">// calling the start method. If any valid response data is returned it requests</span>

<span class="co1">// every five seconds. If no data is retrieved it adds five seconds to the</span>
<span class="co1">// interval until the next request that returns data resets the interval.</span>
<span class="co1">// This example uses a limit so the maximum interval will be 15 seconds.</span>
</pre>
      <h2 id="Request:startTimer"><a href="#Request:startTimer">Request Method: startTimer</a></h2>
      <p class="description">Starts requesting the URL given by the initial options</p>
      <h3>Syntax</h3>
      <pre class="javascript">myRequest.<span class="me1">startTimer</span><span class="br0">(</span>data<span class="br0">)</span>;
</pre>
      <h3>Arguments</h3>
      <ol>
        <li>data - (<em>object</em>) The data you want to send along with your requests</li>
      </ol>
      <h3>Example</h3>
      <pre class="javascript"><span class="kw2">var</span> foo = <span class="kw2">new</span> Request<span class="br0">(</span><span class="br0">{</span>url: <span class="st0">'foo.php'</span><span class="br0">}</span><span class="br0">)</span>;
foo.<span class="me1">startTimer</span><span class="br0">(</span><span class="br0">{</span>myData: <span class="st0">'value'</span><span class="br0">}</span><span class="br0">)</span>;

</pre>
      <h3>Returns</h3>
      <ul>
        <li> <em>object</em> - This instance of Request.</li>
      </ul>
      <h2 id="Request:stopTimer"><a href="#Request:stopTimer">Request Method: stopTimer</a></h2>
      <p class="description">Stops the timer and does not execute any more requests beside an already running request.</p>
      <h3>Syntax</h3>
      <pre class="javascript">myRequest.<span class="me1">stopTimer</span><span class="br0">(</span><span class="br0">)</span>;
</pre>
      <h3>Returns</h3>
      <ul>
        <li> <em>object</em> - This instance of Request.</li>
      </ul>
    </div>
  </div>
<script type="text/javascript" src="../../../assets/mootools-core-1.3.js"></script>
<script type="text/javascript" src="../../../assets/mootools-more-smoothscroll.js"></script>
<script type="text/javascript" src="../../../assets/doc-assist.js"></script>
</body>
</html>
